package 数据结构.栈.链表栈;

import 数据结构.栈.Stack;
import 数据结构.链表.LinkedList;

/**
 * @author Veng Su 1344114844@qq.com
 * @date 2018/7/20 14:37
 */
public class LinkedListStack<E> implements Stack<E> {
    private LinkedList<E> linkedList;

    public LinkedListStack() {
        this.linkedList = new LinkedList<>();
    }

    @Override
    public int getSize() {
        return linkedList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return linkedList.isEmpty();
    }

    @Override
    public void push(E e) {
        linkedList.addFirst(e);
    }

    @Override
    public E pop() {
        return linkedList.removeFirst();
    }

    @Override
    public E peek() {
        return linkedList.getFirst();
    }

    @Override
    public String toString() {
        return "Stack : top " +
                linkedList;
    }
}
